package com.qinggeng.project.tool.third.controller;

import com.qinggeng.common.utils.poi.ExcelUtil;
import com.qinggeng.framework.aspectj.lang.annotation.Log;
import com.qinggeng.framework.aspectj.lang.enums.BusinessType;
import com.qinggeng.framework.web.controller.BaseController;
import com.qinggeng.framework.web.domain.AjaxResult;
import com.qinggeng.framework.web.page.TableDataInfo;
import com.qinggeng.project.tool.third.domain.SysThirdPlatform;
import com.qinggeng.project.tool.third.service.ISysThirdPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * 第三方平台信息Controller
 *
 * @author qinggeng
 * @date 2020-03-13
 */
@RestController
@RequestMapping("/tool/thirdPlatform")
public class SysThirdPlatformController extends BaseController
{
    @Autowired
    private ISysThirdPlatformService sysThirdPlatformService;

    /**
     * 查询第三方平台信息列表
     */
    @PreAuthorize("@ss.hasPermi('tool:thirdPlatform:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysThirdPlatform sysThirdPlatform)
    {
        startPage();
        List<SysThirdPlatform> list = sysThirdPlatformService.selectSysThirdPlatformList(sysThirdPlatform);
        return getDataTable(list);
    }

    /**
     * 导出第三方平台信息列表
     */
    @PreAuthorize("@ss.hasPermi('tool:thirdPlatform:export')")
    @Log(title = "第三方平台信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysThirdPlatform sysThirdPlatform)
    {
        List<SysThirdPlatform> list = sysThirdPlatformService.selectSysThirdPlatformList(sysThirdPlatform);
        ExcelUtil<SysThirdPlatform> util = new ExcelUtil<SysThirdPlatform>(SysThirdPlatform.class);
        return util.exportExcel(list, "thirdPlatform");
    }

    /**
     * 获取第三方平台信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('tool:thirdPlatform:query')")
    @GetMapping(value = "/{platformId}")
    public AjaxResult getInfo(@PathVariable("platformId") Long platformId)
    {
        return AjaxResult.success(sysThirdPlatformService.selectSysThirdPlatformById(platformId));
    }

    /**
     * 新增第三方平台信息
     */
    @PreAuthorize("@ss.hasPermi('tool:thirdPlatform:add')")
    @Log(title = "第三方平台信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysThirdPlatform sysThirdPlatform)
    {
        return toAjax(sysThirdPlatformService.insertSysThirdPlatform(sysThirdPlatform));
    }

    /**
     * 修改第三方平台信息
     */
    @PreAuthorize("@ss.hasPermi('tool:thirdPlatform:edit')")
    @Log(title = "第三方平台信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysThirdPlatform sysThirdPlatform)
    {
        return toAjax(sysThirdPlatformService.updateSysThirdPlatform(sysThirdPlatform));
    }

    /**
     * 删除第三方平台信息
     */
    @PreAuthorize("@ss.hasPermi('tool:thirdPlatform:remove')")
    @Log(title = "第三方平台信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{platformIds}")
    public AjaxResult remove(@PathVariable Long[] platformIds)
    {
        return toAjax(sysThirdPlatformService.deleteSysThirdPlatformByIds(platformIds));
    }
}
